package com.wry.spring.extension;

import com.wry.spring.service.OrderService;
import com.wry.spring.service.impl.OrderServiceImpl;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.stereotype.Component;

/**
 * <h1> 获取BeanFactory对象 </h1>
 *
 * @author wry
 * @since 2025.04.06
 */
@Component
public class MyBeanFactoryAware implements BeanFactoryAware, BeanNameAware {

    @Override
    public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
        OrderServiceImpl orderService = (OrderServiceImpl) beanFactory.getBean("orderServiceImpl");
        System.out.println("BeanFactory -> " + orderService);
    }

    @Override
    public void setBeanName(String s) {

    }
}
